import { mock } from '@/utils/requestMock';

// 巡视数据查询树mock数据 - 匹配实际API响应格式
const patrolDataSearchTreeMock = [
  {
    inspection_area_name: "巡视区1",
    inspection_area_id: 1,
    data_set_list: [
      "数据集1",
      "数据集2"
    ]
  },
  {
    inspection_area_name: "巡视区2", 
    inspection_area_id: 2,
    data_set_list: [
      "火星土壤分析数据集",
      "火星磁场测量数据集",
      "火星温度分布数据集"
    ]
  },
  {
    inspection_area_name: "巡视区3",
    inspection_area_id: 3,
    data_set_list: [
      "月球表面矿物数据集",
      "月球重力场数据集"
    ]
  }
];

// 巡视数据查询探测点文件mock数据
const patrolDataSearchDetectionPointFileMock = [
  {
    id: 1,
    create_time: "2025-01-15 10:30:00",
    update_time: "2025-01-15 10:30:00",
    detection_strat_time: "2025-01-15 10:30:00",
    detection_end_time: "2025-01-15 11:30:00",
    planet_id: 1,
    detection_name: "火星探测点001",
    detection_num: "MARS001",
    latitude: 15.5,
    longitude: 45.2,
    is_special: 0,
    data_file_list: [
      {
        id: 1,
        inspection_area_id: 1,
        detection_point_id: 1,
        data_set_id: 1,
        create_time: "2025-01-15 10:30:00",
        update_time: "2025-01-15 10:30:00",
        planet_id: 1,
        file_name: "火星地形数据_001.img",
        file_path: "/data/mars/terrain/001.img",
        file_sizes: 1024000,
        task: "TW1",
        dm_zhname: "CCD",
        data_leve: "OA"
      },
      {
        id: 2,
        inspection_area_id: 1,
        detection_point_id: 1,
        data_set_id: 1,
        create_time: "2025-01-15 10:35:00",
        update_time: "2025-01-15 10:35:00",
        planet_id: 1,
        file_name: "火星地形数据_002.img",
        file_path: "/data/mars/terrain/002.img",
        file_sizes: 2048000,
        task: "TW1",
        dm_zhname: "CCD",
        data_leve: "OA"
      }
    ]
  },
  {
    id: 2,
    create_time: "2025-01-15 11:00:00",
    update_time: "2025-01-15 11:00:00",
    detection_strat_time: "2025-01-15 11:00:00",
    detection_end_time: "2025-01-15 12:00:00",
    planet_id: 1,
    detection_name: "火星探测点002",
    detection_num: "MARS002",
    latitude: -25.3,
    longitude: 120.8,
    is_special: 1,
    data_file_list: [
      {
        id: 3,
        inspection_area_id: 1,
        detection_point_id: 2,
        data_set_id: 1,
        create_time: "2025-01-15 11:00:00",
        update_time: "2025-01-15 11:00:00",
        planet_id: 1,
        file_name: "火星大气数据_001.dat",
        file_path: "/data/mars/atmosphere/001.dat",
        file_sizes: 512000,
        task: "TW2",
        dm_zhname: "光谱仪",
        data_leve: "L1A"
      }
    ]
  },
  {
    id: 3,
    create_time: "2025-01-15 12:30:00",
    update_time: "2025-01-15 12:30:00",
    detection_strat_time: "2025-01-15 12:30:00",
    detection_end_time: "2025-01-15 13:30:00",
    planet_id: 1,
    detection_name: "火星探测点003",
    detection_num: "MARS003",
    latitude: 35.7,
    longitude: -80.5,
    is_special: 0,
    data_file_list: [
      {
        id: 4,
        inspection_area_id: 2,
        detection_point_id: 3,
        data_set_id: 3,
        create_time: "2025-01-15 12:30:00",
        update_time: "2025-01-15 12:30:00",
        planet_id: 1,
        file_name: "火星土壤数据_001.txt",
        file_path: "/data/mars/soil/001.txt",
        file_sizes: 256000,
        task: "TW3",
        dm_zhname: "X射线衍射仪",
        data_leve: "L2A"
      },
      {
        id: 5,
        inspection_area_id: 2,
        detection_point_id: 3,
        data_set_id: 3,
        create_time: "2025-01-15 12:35:00",
        update_time: "2025-01-15 12:35:00",
        planet_id: 1,
        file_name: "火星土壤数据_002.txt",
        file_path: "/data/mars/soil/002.txt",
        file_sizes: 384000,
        task: "TW3",
        dm_zhname: "X射线衍射仪",
        data_leve: "L2A"
      },
      {
        id: 6,
        inspection_area_id: 2,
        detection_point_id: 3,
        data_set_id: 4,
        create_time: "2025-01-15 12:40:00",
        update_time: "2025-01-15 12:40:00",
        planet_id: 1,
        file_name: "火星磁场数据_001.mag",
        file_path: "/data/mars/magnetic/001.mag",
        file_sizes: 128000,
        task: "TW4",
        dm_zhname: "磁力计",
        data_leve: "L1B"
      }
    ]
  }
];

// 巡视数据查询树接口
mock('GET', '/GIS/GISInspectDataSearchTree', () => patrolDataSearchTreeMock);

// 巡视数据查询探测点文件接口
mock('GET', '/GIS/GISInspectDataSearchDetectionPointFile', (config) => {
  const planetId = parseInt(config.params?.planet_id);
  const inspectionAreaId = parseInt(config.params?.inspection_area_id);
  const dataSetName = config.params?.data_set_name;
  
  console.log('Mock接口调用参数:', { planetId, inspectionAreaId, dataSetName });
  
  // 根据巡视区ID和数据集名称返回不同的数据
  if (inspectionAreaId === 1) {
    // 巡视区1
    if (!dataSetName) {
      // 点击巡视区，返回该巡视区下所有探测点
      return patrolDataSearchDetectionPointFileMock.slice(0, 2);
    } else if (dataSetName === "数据集1") {
      return patrolDataSearchDetectionPointFileMock.slice(0, 1);
    } else if (dataSetName === "数据集2") {
      return patrolDataSearchDetectionPointFileMock.slice(1, 2);
    }
  } else if (inspectionAreaId === 2) {
    // 巡视区2
    if (!dataSetName) {
      // 点击巡视区，返回该巡视区下所有探测点
      return patrolDataSearchDetectionPointFileMock.slice(2, 3);
    } else if (dataSetName === "火星土壤分析数据集") {
      return patrolDataSearchDetectionPointFileMock.slice(2, 3);
    } else if (dataSetName === "火星磁场测量数据集") {
      return patrolDataSearchDetectionPointFileMock.slice(2, 3);
    } else if (dataSetName === "火星温度分布数据集") {
      return [];
    }
  } else if (inspectionAreaId === 3) {
    // 巡视区3
    if (!dataSetName) {
      // 点击巡视区，返回该巡视区下所有探测点
      return [
        {
          id: 4,
          create_time: "2025-01-16 09:00:00",
          update_time: "2025-01-16 09:00:00",
          detection_strat_time: "2025-01-16 09:00:00",
          detection_end_time: "2025-01-16 10:00:00",
          planet_id: 2,
          detection_name: "月球探测点001",
          detection_num: "MOON001",
          latitude: 20.5,
          longitude: 30.2,
          is_special: 0,
          data_file_list: [
            {
              id: 7,
              inspection_area_id: 3,
              detection_point_id: 4,
              data_set_id: 6,
              create_time: "2025-01-16 09:00:00",
              update_time: "2025-01-16 09:00:00",
              planet_id: 2,
              file_name: "月球矿物数据_001.min",
              file_path: "/data/moon/mineral/001.min",
              file_sizes: 768000,
              task: "TW5",
              dm_zhname: "矿物光谱仪",
              data_leve: "L2B"
            }
          ]
        },
        {
          id: 5,
          create_time: "2025-01-16 10:30:00",
          update_time: "2025-01-16 10:30:00",
          detection_strat_time: "2025-01-16 10:30:00",
          detection_end_time: "2025-01-16 11:30:00",
          planet_id: 2,
          detection_name: "月球探测点002",
          detection_num: "MOON002",
          latitude: -15.8,
          longitude: 150.3,
          is_special: 1,
          data_file_list: [
            {
              id: 8,
              inspection_area_id: 3,
              detection_point_id: 5,
              data_set_id: 7,
              create_time: "2025-01-16 10:30:00",
              update_time: "2025-01-16 10:30:00",
              planet_id: 2,
              file_name: "月球重力数据_001.grv",
              file_path: "/data/moon/gravity/001.grv",
              file_sizes: 1024000,
              task: "TW6",
              dm_zhname: "重力计",
              data_leve: "L1A"
            }
          ]
        }
      ];
    } else if (dataSetName === "月球表面矿物数据集") {
      return [
        {
          id: 4,
          create_time: "2025-01-16 09:00:00",
          update_time: "2025-01-16 09:00:00",
          detection_strat_time: "2025-01-16 09:00:00",
          detection_end_time: "2025-01-16 10:00:00",
          planet_id: 2,
          detection_name: "月球探测点001",
          detection_num: "MOON001",
          latitude: 20.5,
          longitude: 30.2,
          is_special: 0,
          data_file_list: [
            {
              id: 7,
              inspection_area_id: 3,
              detection_point_id: 4,
              data_set_id: 6,
              create_time: "2025-01-16 09:00:00",
              update_time: "2025-01-16 09:00:00",
              planet_id: 2,
              file_name: "月球矿物数据_001.min",
              file_path: "/data/moon/mineral/001.min",
              file_sizes: 768000,
              task: "TW5",
              dm_zhname: "矿物光谱仪",
              data_leve: "L2B"
            }
          ]
        }
      ];
    } else if (dataSetName === "月球重力场数据集") {
      return [
        {
          id: 5,
          create_time: "2025-01-16 10:30:00",
          update_time: "2025-01-16 10:30:00",
          detection_strat_time: "2025-01-16 10:30:00",
          detection_end_time: "2025-01-16 11:30:00",
          planet_id: 2,
          detection_name: "月球探测点002",
          detection_num: "MOON002",
          latitude: -15.8,
          longitude: 150.3,
          is_special: 1,
          data_file_list: [
            {
              id: 8,
              inspection_area_id: 3,
              detection_point_id: 5,
              data_set_id: 7,
              create_time: "2025-01-16 10:30:00",
              update_time: "2025-01-16 10:30:00",
              planet_id: 2,
              file_name: "月球重力数据_001.grv",
              file_path: "/data/moon/gravity/001.grv",
              file_sizes: 1024000,
              task: "TW6",
              dm_zhname: "重力计",
              data_leve: "L1A"
            }
          ]
        }
      ];
    }
  }
  
  // 默认返回空数据
  return [];
});
